package org.Component;

import com.sun.beans.editors.FontEditor;
import org.implement.Panel.PanelSize;
import org.implement.Panel.PanelSkip;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class PostMenuBar extends JPanel {

    //搜索栏
    SearchPanel searchPanel;
    //我的个人主页按钮
    JLabel myPersonal = new JLabel("我的");
    //母控件大小接口
    PanelSize panelSize;
    //母控件跳转接口
    PanelSkip panelSkip;

    public PostMenuBar(PanelSize panelSize, PanelSkip panelSkip) {

        this.panelSize = panelSize;
        this.panelSkip = panelSkip;

        //菜单属性
        setLayout(null);
        setBounds(0,0,panelSize.getWidth(),100);

        //我的按钮设置
        myPersonal.setBounds(getWidth()-50,10,50,30);
        //设置字体
        Font fon = new Font(null,0,20);
        myPersonal.setFont(fon);
        myPersonal.addMouseListener(new MouseAdapter() {
            int f = 1;
            @Override
            public void mousePressed(MouseEvent e) {
                super.mousePressed(e);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if(f==1) {

                    //进入个人界面
                    panelSkip.skip(3);
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                f=1;
                //鼠标移动至文本中,改变鼠标指针样式
                myPersonal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                //将文字颜色改为蓝色
                myPersonal.setForeground(Color.BLUE);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                f=0;
                //当鼠标移出文本时,回复文字颜色黑色
                myPersonal.setForeground(Color.BLACK);
            }
        });

        //搜索栏
        searchPanel = new SearchPanel(panelSize,panelSkip);

        //添加至菜单界面
        add(myPersonal);
        add(searchPanel);

    }
}
